package sjtu.ist.warehouse4ws.model.file;

import java.util.ArrayList;


import sjtu.ist.warehouse4ws.jcr.RepositoryMoudl;

public class FileFolderImp implements FileFolder{
	private String name;
	private String path;
	ArrayList<File> files;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}
	public FileFolderImp(String path){
		this.path=path;
	}
	public FileFolderImp(String name,String path){
		this.name=name;
		this.path=path;
	}
	public void fileInit(RepositoryMoudl rm)
	{
		files = new ArrayList<File>();
		ArrayList<String> names = rm.getNodesNames(path);
		ArrayList<String> paths =rm.getNodesPathes(path);
		for (int i = 0; i < names.size(); i++) {
			files.add(new FileImp(names.get(i),paths.get(i)));
		}
	}
	public ArrayList<File> getFiles(RepositoryMoudl rm)
	{
		if(files==null)fileInit(rm);
		return files;
	}
}
